﻿@{
    ViewBag.Title = "ProductTypeManagement";
}
<script src="~/Scripts/jquery.hiMallDatagrid.js"></script>
<script src="~/Scripts/CommonJS.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>

<script type="text/javascript">
    function deleteTypeEvent(id) {
        $.dialog.confirm('您确定要删除该类型吗？', function () {
            var loading = showLoading();
            ajaxRequest({
                type: 'POST',
                url: './DeleteType',
                cache: false,
                param: { Id: id },
                dataType: 'json',
                success: function (data) {
                    loading.close();
                    if (data.success == true)
                        location.href = './Management';
                    else {
                        $.dialog.tips(data.msg);
                    }
                },
                error: function (data) {
                    loading.close(); $.dialog.tips(data.msg);
                }
            })
        });
    }

    function Query() {

        var que = $("#searchKeyWord").val();
        $("#typeDatagrid").hiMallDatagrid({
            url: "./DataGridJson",
            singleSelect: true,
            pagination: true,
            NoDataMsg: '没有找到符合条件的数据',
            idField: "Id",
            pageSize: 20,
            pageNumber: 1,
            queryParams: { "searchKeyWord": que },
            toolbar: "#typeToolBar",
            columns:
            [[

                { field: "Id", title: "Id", width: 105, hidden: true },
                { field: "Name", title: "名称", width: 640 },
                {
                    field: "operation", operation: true, title: "操作",
                    formatter: function (value, row, index) {
                        var id = row.Id.toString();
                        var html = ['<span class="btn-a">'];
                        html.push('<a href="./Edit?id=' + id + '">编辑</a>');
                        html.push('<a onclick="deleteTypeEvent(' + id + ');">删除</a>');
                        html.push("</span>");

                        return html.join("");
                    }
                }
            ]]
        });

    };

    $(function () {

        Query();
        $("#searchBtn").click(function () { Query(); });

    });
</script>
<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>类型</strong>
        <li class="active"><a>管理</a></li>
        <li><a href="./Edit?id=0">新增</a></li>

        <em class="primary-btn">
            <span class="glyphicon glyphicon-question-sign"></span>
            <div class="primary">
                <h3>温馨提示：</h3>
                <span>*</span><p>类型是指某类具有相同描述特征的商品属性的集合，这个属性集合包括品牌、属性、规格。例如服装类型下的男装、女装都可以使用同一系品牌（NIKE、李宁）、属性（风格、材质）、规格（颜色、尺码）等</p>
            </div>
        </em>

    </ul>

    <div id="typeToolBar">
        <div class="search-box only-line">
            <form class="custom-inline" role="form">
                <div class="form-group"><input class="form-control input-ssm" type="text" id="searchKeyWord"></div>
                <input type="button" value="搜 索" id="searchBtn" class="btn btn-primary btn-sm">
            </form>
        </div>
    </div>

    <table id="typeDatagrid" class="table"></table>
</div>

